.TH "mock" "1" "@VERSION@" "Seth Vidal" ""
.SH "NAME"
.LP
mock \- build SRPMs in a chroot
.SH "SYNTAX"
.LP
mock  [options] \fB\-\-rebuild\fR \fISRPM [\fISRPM...\fR]
.LP
mock  [options] \fB\-\-chain\fR \fISRPM [\fISRPM...\fR]
.LP
mock  [options] \fB\-\-buildsrpm\fR {\-\-spec \fIspec\fR \-\-sources \fIsrc\fR \-\-symlink\-dereference | \-\-scm\-enable}
.LP
mock  [options] \fB\-\-chroot\fR \fI<cmd>\fR
.LP
mock  [options] {\fB\-\-init\fR|\fBclean\fR|\fBshell\fR}
.LP
mock  [options] \fB\-\-installdeps\fR {SRPM|RPM|SPEC}
.LP
mock  [options] \fB\-i\fR, \fB\-\-install\fR PACKAGE [\fIPACKAGE...\fR]
.LP
mock  [options] \fB\-\-update\fR [\fIPACKAGE...\fR]
.LP
mock  [options] \fB\-\-remove\fR PACKAGE [\fIPACKAGE...\fR]
.LP
mock  [options] \fB\-\-orphanskill\fR
.LP
mock  [options] \fB\-p\fR, \fB\-\-print\-root\-path\fR
.LP
mock  [options] \fB\-\-copyin\fR \fIpath [\fIpath...\fR] \fIdestination\fR
.LP
mock  [options] \fB\-\-copyout\fR \fIpath [\fIpath...\fR] \fIdestination\fR
.LP
mock  [options] \fB\-\-scm\-enable\fR [\fI\-\-scm\-option key=value ...\fR]
.LP
mock  [options] \fB\-l\fR, \fB\-\-list\-snapshots\fR
.LP
mock  [options] \fB\-\-snapshot\fR [\fIsnapshot\-name\fR]
.LP
mock  [options] \fB\-\-rollback\-to\fR [\fIsnapshot\-name\fR]
.LP
mock  [options] \fB\-\-remove\-snapshot\fR [\fIsnapshot\-name\fR]
.LP
mock  [options] \fB\-\-umount\fR
.LP
mock  [options] \fB\-\-pm\-cmd\fR [\fIarguments ...\fR]
.LP
mock  [options] \fB\-\-yum\-cmd\fR [\fIarguments ...\fR]
.LP
mock  [options] \fB\-\-dnf\-cmd\fR [\fIarguments ...\fR]


.SH "DESCRIPTION"
.LP
Mock is a simple program that will build source RPMs inside a chroot. It
doesn't do anything fancy other than populating a chroot with the
contents specified by a configuration file, then build any input SRPM(s) in
that chroot.
.LP
The content of a chroot is specified by the configuration specified with the
\fB\-r\fR option. The default configuration file is /etc/mock/default.cfg,
which is usually a symlink to one of the installed configurations.
.LP
There is a site\-wide configuration file, /etc/mock/site\-defaults.cfg, which can
be used to specify site\-wide options. The shipped version of this file has no
active options, but does have a list of all of the configuration options
examples of how to set them, and their default values.
.LP
To change configuration only for the current user please use ~/.config/mock.cfg
configuration file.
.LP
For backward compatibility, old\-style commands, ("rebuild", "init", "clean",
etc.) without leading '\-\-' are still accepted, but are deprecated. See
COMMANDS section, below, for the detailed listing of all commands.
.LP
To use mock, a user should become a member of the \fBmock\fR group by
adding their username to the \fBmock\fR line in /etc/group. This can
be done with the following command:
.P
        \fBsudo /usr/sbin/usermod \-a \-G mock $USER\fR

Note that mock is not intended to be run directly as root.
.LP
Warning:
Mock is running some parts of code with root privileges. There are known ways to get root access once a user is in mock group (and once he is able to run mock). This is possible when a user abuses the mock configuration options. Please do not add anyone who is not trustworthy to the mock group!


.SH "COMMANDS"
.LP
.TP
\fB\-\-buildsrpm\fP
Build the specified SRPM either from a spec file and source file/directory or SCM. The chroot (including the results directory) is cleaned first, unless \-\-no\-clean is specified.
.TP
\fB\-\-chain\fR
When passing more than one SRPM, it will try to build failed builds if at least one subsequent SRPM succeed. This mimic the behaviour of deprecated mockchain.
.TP
\fB\-\-clean\fP
Purge the chroot tree.
.TP
\fB\-\-copyin\fP
Copies the source paths (files or directory trees) into the chroot at
the specified destination path.
.TP
\fB\-\-copyout\fP
Copies the source paths (files or directory trees) from the chroot to
the specified destination path.
.TP
\fB\-\-chroot\fP [\fI\-\-\fR] \fICOMMAND\fR [\fIARGS...\fR]
Run the specified command non\-interactively within the chroot (no
\fB\-\-clean\fR is performed).

This mode is similar to \fishell\fR mode, except that the output \fBis logged\fR
and the \fICOMMAND\fR and \fIARGS\fR arguments are not shell expanded in chroot
when the variant with \fICMD+ARGS\fR is used, see the difference in mock output:
    \fBmock --quiet --chroot -- echo '*'\fR
    *
    \fBmock --quiet --chroot -- 'echo *'\fR
    bin boot builddir dev etc home lib lib64 media mnt opt ...
See also \fB\-\-shell\fR.
.TP
\fB\-\-debug-config\fP
Print all options in config_opts.
.TP
\fB\-\-debug-config-expanded\fP
Prints all options in config_opts with jinja template values already expanded.
.TP
\fB\-\-dnf\-cmd\fP
Execute following arguments with DNF with installroot set to the chroot path. DNF must be installed on the system.
It will use the binary which is specified in 'dnf_command' option in site-defaults.cfg config, which by default is /usr/bin/dnf.
This option will enforce \-\-dnf.
.TP
\fB\-\-init\fP
Initialize a chroot (clean, install chroot packages, etc.).
.TP
\fB\-i\fR, \fB\-\-install\fP
Do a yum install PACKAGE inside the chroot. No 'clean' is performed.
.TP
\fB\-\-installdeps\fP
Find out deps for SRPM or RPM, and do a yum install to put them in the chroot. No 'clean' is performed
.TP
\fB\-l\fR, \fB\-\-list\-snapshots\fP
List all existing snapshots of the chroot belonging to the current configuration.
Current base snapshot is marked with an asterisk (\fB*\fR)
.TP
\fB\-\-mount\fP
Mount all everything mounted in the chroot path including the root itself
that might have been an LVM volume, TMPFS or overlayfs.
.TP
\fB\-\-orphanskill\fP
No\-op mode that simply checks that no stray processes are running in the chroot. Kills any processes that it finds using the specified root.
.TP
\fB\-\-pm\-cmd\fP
Execute following arguments with the current package manager with installroot set to
the chroot path.
.TP
\fB\-p\fR, \fB\-\-print\-root\-path\fP
Prints a path to the currently used chroot directory.
.TP
\fB\-\-rebuild\fP
If no command is specified, rebuild is assumed. Rebuild the specified SRPM(s). The chroot (including the results directory) is cleaned first, unless \-\-no\-clean is specified.
.TP
\fB\-\-remove\fP
Do a yum remove PACKAGE inside the chroot. No 'clean' is performed.
.TP
\fB\-\-remove\-snapshot\fP
Remove given snapshot freeing the space it occupied. This action cannot be
undone.
This feature is available only when lvm_root or overlayfs plugin is installed and enabled.
.TP
\fB\-\-rollback\-to\fP
Return chroot to the state in the specified snapshot and set it as the current
base to which clean actions will return. It won't delete nor modify the snapshot
that was set as base previously.
This feature is available only when the lvm_root or overlayfs plugin is installed and enabled.
.TP
\fB\-\-scm\-enable\fP
Enable building from an SCM (CVS/Git/SVN/DistGit). The SCM repository must be
configured in site\-defaults.cfg before SCM checkouts are possible. SCM
package and branch can be defined with \fB\-\-scm\-option\fP arguments,
see site\-defaults.cfg for more information.
.TP
\fB\-\-scrub\fR=\fITYPE\fP
Completely remove the specified chroot or cache dir or all of the chroot and cache.  \fITYPE\fR is one of all, chroot, bootstrap, cache, root\-cache, c\-cache, yum\-cache or dnf\-cache. In fact, dnf\-cache is just alias for yum\-cache, and both remove Dnf and Yum cache.
.TP
\fB\-\-shell\fP [\fI\-\-\fR] [\fICOMMAND\fR [\fIARGS...\fR]]
Shell mode.  Run the specified command interactively within the chroot (no
\fB\-\-clean\fR is performed).  If no command specified, \fB/bin/sh\fR is run
and prompt is provided.

Be aware that mock first parses all the command-line arguments, so the
\fIARGS\fR could be mistakenly evaluated as mock's options.  Thats why you
almost always want to use the \fI\-\-\fR separator.

This mode does not produce logs (nothing is appended to \fBroot.log\fR in
\fB\-\-resultdir\fR).

The \fICOMMAND\fR and \fIARGS\fR are shell expanded using the shell in chroot
(unless they mistakenly expand in host's terminal shell).  E.g. the following
two commands are equivalent:
    \fBmock \-\-shell \-\- ls \-l '*'\fR
    \fBmock \-\-shell 'ls \-l *'\fR
.br
But the following is something entierly different:
    \fBmock \-\-shell \-\- ls \-l *\fR
.TP
\fB\-\-sources\fR=\fISOURCES\fP
Specifies sources (either a single file or a directory of files) to use to build an SRPM (used only with \-\-buildsrpm).
.TP
\fB\-\-spec\fR=\fISPEC\fP
Specifies spec file to use to build an SRPM.
.TP
\fB\-\-update\fP [\fIPACKAGE...]\fR
Do a package update inside the chroot. The package list is optional, if omitted, all packages will be updated. No 'clean' is performed.
.TP
\fB\-\-snapshot\fP
Make a snapshot of the current state of the chroot. That snapshot will be set
as the current base to which \fV\-\-clean\fP and implicit clean happening during
rebuild command will return.
This feature is available only when the lvm_root or overlayfs plugin is installed and enabled.
.TP
\fB\-\-umount\fP
Umount all everything mounted in the chroot path including the root itself
that might have been an LVM volume, TMPFS or overalyfs.
.TP
\fB\-\-yum\-cmd\fP
Execute following arguments with YUM with installroot set to the chroot path. Yum must be installed on the system.
It will use the binary which is specified in 'yum_command' option in site-defaults.cfg config, which by default is /usr/bin/yum.
Note that in config files for Fedora 22\+ this value is overwritten in chroot config to default to /usr/bin/yum-deprecated.
This option will enforce \-\-yum.
.TP
Note: While you can specify more commands on a command line, only one can be executed. The last command will win.


.SH "OPTIONS"
.LP
.TP
\fB\-a\fR, \fB\-\-addrepo\fR=\fIREPO\fP
Add this repo baseurl to the yumconfig for the chroot. This can be specified
multiple times. Let's you point to multiple paths beyond the default to pull
build deps from.

.TP
\fB\-\-arch\fR=\fIARCH\fP
Calls the Linux personality() syscall to tell the kernel to emulate a secondary architecture. For example, building i386 packages on an x86_64 buildhost.
.TP
\fB\-\-additional\-package\fR=\fIPACKAGE\fP
An additional package (on top of in-package specified BuildRequires) to be
installed into the buildroot before the build is done.  Can be specified
multiple times.  Works only with \fB\-\-rebuild\fR.
.TP
\fB\-\-forcearch\fR=\fIARCH\fP
Pass \-\-forcearch to DNF. This will enable to install packages for different architecture. Works only for DNF and you have to have package qemu-user-static installed.
.TP
\fB\-\-cache\-alterations\fR
Rebuild the root cache after making alterations to the chroot (i.e. \-\-install). This option is useful only when using tmpfs plugin.
.TP
\fB\-\-cleanup\-after\fR
Clean chroot after building. Use with \-\-resultdir. Only active for '\-\-rebuild'.
.TP
\fB\-\-configdir\fR=\fICONFIGDIR\fP
Change directory where config files are found
.TP
\fB\-\-config-opts\fR=\fIKEY=VALUE\fP
Override configuration option. Can be used multiple times. When used multiple times for the same key, it will create an array. This is evaluated first (after parsing configs) so any specialized command line option can override values defined in this option.
.TP
\fB\-\-continue\fR
If a pkg fails to build, continue to the next one, default is to stop.

Works only with \fB\-\-chain\fR.
.TP
\fB\-\-cwd\fR=\fIDIR\fP
Change to the specified directory (relative to the chroot) before running command when using \-\-chroot or \-\-shell.
.TP
\fB\-D \fR"\fIMACRO EXPR\fP", \fB\-\-define\fR="\fIMACRO EXPR\fP"
Specify macro definitions used for the build.  This option may be used multiple times, just as the rpmbuild \-\-define option can be.  For example:

\fB\-\-define "with_extra_cheese 1" \-\-define="packager Monkey"\fR
.TP
\fB\-\-disable\-plugin\fR=\fIPLUGIN\fP
Disable the specified plugin.  This option may be used multiple times.
.TP
\fB\-\-disablerepo\fR=\fIREPO\fR
Pass \fB\-\-disablerepo\fR option to package manager to disable a repository.
It can be specified multiple times.
.TP
\fB\-\-dnf\fR
Use DNF as the current package manager. You should have DNF (and dnf-plugins-core) installed on your system. This is the default.
.TP
\fB\-\-enable\-plugin\fR=\fIPLUGIN\fP
Enable the specified plugin.  This option may be used multiple times.
.TP
\fB\-\-enablerepo\fR=\fIREPO\fR
Pass \fB\-\-enablerepo\fR option to package manager to enable a repository.
It can be specified multiple times.
.TP
\fB\-\-enable\-network\fR
Enable networking. If you want to have reproducible builds then your builds should run without a network.
This option overrides config_opts['rpmbuild_networking'] and config_opts['use_host_resolv'], setting both True.
.TP
\fB\-\-isolation\fR={\fIauto\fR|\fInspawn\fR|\fIsimple\fR}
What should be used for isolation of chroot.  The \fIsimple\fR method uses
chroot() call.  The \fInspawn\fR  method utilizes systemd-nspawn(1) and runs the
commands inside container.  The \fIauto\fR tries to use \fInspawn\fR, and falls
back to \fIsimple\fR if system-nspawn can not be used (e.g. if mock is run in
container).  The default is \fIauto\fR.
.TP
\fB\-\-localrepo\fR=\fIREPO\fR\fR
Set the path to put the results/repo in (works only in \fB\-\-chain\fR mode).
Will make a tempdir if not set.
.TP
\fB\-c\fR
If package fails, continue to the next one (works only in \fB\-\-chain\fR mode).
.TP
\fB\-h\fR, \fB\-\-help\fR
Show usage information and exit.
.TP
\fB\-\-macro\-file\fR=\fIFILE\fR
Use pre\-defined rpm macro file. Macros passed to '\-\-define' override macros of the same name from FILE.
.TP
\fB\-\-new\-chroot\fR
Deprecated. Use \fV\-\-isolation=nspawn\fP.
.TP
\fB\-n\fR, \fB\-\-no\-clean\fR
Do not clean chroot before building a package.
.TP
\fB\-\-nocheck\fR
Pass \-\-nocheck to rpmbuild to skip 'make check' tests.
.TP
\fB\-N\fR, \fB\-\-no\-cleanup\-after\fR
Don't clean chroot after building. If automatic cleanup is enabled, use this to disable.
.TP
\fB\-\-offline\fR
Run in an 'offline' mode where we tell 'yum' to run completely from the local cache. Also, disables cache expiry for the mock yum cache.
.TP
\fB\-\-old\-chroot\fR
Deprecated. Use \fV\-\-isolation=simple\fP.
.TP
\fB\-\-plugin\-option \fR\fIPLUGIN\fR\fB:\fR\fIKEY\fR\fB=\fR\fIVALUE\fP
Set plugin specific parameter. This option may be used multiple times.
Examples:

\fB\-\-plugin\-option=root_cache:age_check=False\fR

\fB\-\-plugin\-option=mount:dirs=("/dev/device", "/mount/path/in/chroot/", "vfstype", "mount_options")\fR
.TP
\fB\-\-postinstall\fR
Try to install built packages in the same buildroot right after the build.
.TP
\fB\-q\fR, \fB\-\-quiet\fR
Be quiet.
.TP
\fB\-\-recurse\fR
Build all pkgs, record the failures and try to rebuild them again and again
until everything gets built (or until the set of pkgs failing to build are the
same over) sets \fB\-\-continue\fR.  Works only with \fB\-\-chain\fR.
.TP
\fB\-r\fR \fICONFIG\fP, \fB\-\-root\fR=\fICONFIG\fP
Uses specified chroot configuration as defined in
~/.config/mock/<\fICONFIG\fP>.cfg or /etc/mock/<\fICONFIG\fP>.cfg.
Optionally if CONFIG ends in '.cfg', it is
interpreted as full path to config file. If none specified, uses the chroot
config linked to by /etc/mock/default.cfg.
.TP
\fB\-\-resultdir\fR=\fIRESULTDIR\fP
Change directory where resulting files (RPMs and build logs) are written. Resultdir can contain python\-string substitutions for any variable in the chroot config. For example:

\fB\-\-resultdir=./my/"{{dist}}"/"{{target_arch}}"/\fR

This option enables automatic cleanup, this can be changed in config file (by cleanup_on_success, cleanup_on_failure configuration options) or overridden by \-\-no\-cleanup\-after/\-\-cleanup\-after arguments.

Note that this option does not have an effect for \-\-chain command. You can use \-\-localrepo instead.
.TP
\fB\-\-rootdir\fR=\fIROOTDIR\fP
The path for where the chroot should be built. By default it is created in /var/lib/mock/<\fICONFIG\fP>/root/.
.TP
\fB\-\-rpmbuild\-opts\fR=\fIOPTIONS\fR
Pass additional options to rpmbuild. To pass more options, put them in quotes.
.TP
\fB\-\-rpmbuild_timeout\fR=\fISECONDS\fP
Fail build if rpmbuild takes longer than 'timeout' seconds
.TP
\fB\-\-scm\-option\fR=\fIOPTIONS\fR
define an SCM option (may be used more than once).
.TP
\fB\-\-short\-circuit\fR=\fISTAGE\fR
Use rpmbuild's short\-circuit mechanism to skip already executed stages of the build.
It doesn't produce RPMs, and it's useful only for debugging packaging. Implies
\fI\-\-no\-clean\fR. STAGE specifies which stage will be executed as the first.
Available values: prep, build, install, binary.
.TP
\fB\-\-symlink\-dereference\fR
Follow symlinks in sources (used only with \-\-buildsrpm).
.TP
\fB\-\-target\fR=\fIARCH\fP
This argument is passed to rpmbuild to specify the target arch to build. It defaults to whatever is specified for \-\-arch, or whatever is specified in the config file as config_opts['target_arch'].
.TP
\fB\-\-tmp_prefix\fR=\fIPREFIX\fP
Tmp dir prefix - will default to username-pid if not specified.
.TP
\fB\-\-trace\fR
Enables verbose tracing of function enter/exit with function arguments and return codes. Useful for debugging mock itself.
.TP
\fB\-\-uniqueext\fR=\fItext\fP
Arbitrary, unique extension to append to chroot directory name
.TP
\fB\-\-unpriv\fR
Drop privileges before running command when using \-\-chroot
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Output verbose progress information.
.TP
\fB\-\-version\fR
Show version number and exit.
.TP
\fB\-\-with\fR=\fIOPTION\fP
Enable configure OPTION for the build.  This option may be used multiple times.  For example:

\fB\-\-with=extra_cheese\fR
.TP
\fB\-\-without\fR=\fIOPTION\fP
Disable configure OPTION for the build.  This option may be used multiple times.  For example:

\fB\-\-without=anchovies\fR
.TP
\fB\-\-yum\fR
Use yum as the current package manager.

.TP
\fB\-\-bootstrap-chroot\fR
build in two stages, using chroot rpm for creating the build chroot
.TP
\fB\-\-no-bootstrap-chroot\fR
build in a single stage, using system rpm for creating the build chroot

.TP
\fB\-\-use-bootstrap-image\fR
Instead of creating a bootstrap chroot from scrath, use podman image specified in
\fBconfig_opts['bootstrap_image']\fR, extract it, and use it as a cache for the bootstrap chroot.
This is useful when host \fBrpm\fR version is not compatible with the target system, or when using mock
on non-RPM distributions.  This option turns \fB\-\-bootstrap\-chroot\fR on.

.TP
\fB\-\-no-bootstrap-image\fR
don't create bootstrap chroot from container image

.SH "FILES"
.LP
\fI/etc/mock/\fP \- default configuration directory
.LP
\fI/var/lib/mock\fP \- directory where chroots and results are created. You should not put there your input files.
.SH "EXAMPLES"
.LP
To rebuild test.src.rpm using the Fedora 14 configuration for x86_64
.LP
.RS 5
\fBmock \-r fedora\-14\-x86_64 \-\-rebuild /path/to/test.src.rpm
.RE
.LP
Note that the available configurations are found in the /etc/mock
directory with the extension .cfg. To specify a configuration use the
filename without the trailing .cfg extension.
.LP
To place the output RPMs and logs in a specified location.
.LP
.RS 5
\fBmock \-r fedora\-14\-i386 \-\-resultdir=./my\-results /path/to/your.src.rpm\fR
.RE
.LP
To build a package from the default SCM repository configured in site\-defaults.cfg use the following arguments.
.LP
.RS 5
\fBmock \-r fedora\-14\-i386 \-\-scm\-enable \-\-scm\-option package=pkg\fR
.RE
.LP
To execute a command inside of chroot.
.LP
.RS 5
\fBmock \-r fedora\-21\-x86_64 \-\-chroot \-\- rpm --eval %dist\fR
.LP
\fBmock \-r fedora\-21\-x86_64 \-\-chroot 'rpm --eval %dist'\fR
.RE
.LP
To build rawhide package using yum:
.LP
.RS 5
\fBmock \-r fedora\-rawhide\-x86_64 \-\-yum \-\-rebuild your.src.rpm\fR
.RE
.LP
Query rpm database inside chroot using Yum:
.LP
.RS 5
\fBmock \-r fedora\-rawhide\-x86_64 \-\-yum-cmd whatprovides foo\fR
.RE
.LP
List package manager history using package manager which is configured in chroot config (can be either DNF or YUM):
.LP
.RS 5
\fBmock \-r fedora\-rawhide\-x86_64 \-\-pm-cmd history list\fR
.RE

.SH "BUGS"
.LP
To report bugs in mock, go to:
.LP
.RS 5
\fIhttps://apps.fedoraproject.org/packages/mock/\fR.
.RE
.LP
Select the \fBBugs\fR tab. If there is a bug similar to the one you are seeing, add your
information to the comments. If not, press \fBOpen A New Bug\fR and fill in the form.
.SH "AUTHORS"
.LP
Michael Brown <mebrown\@michaels\-house.net>
.LP
Clark Williams <williams\@redhat.com>
.LP
Seth Vidal
.LP
and a cast of...tens
.SH "SEE ALSO"
.LP
rpmbuild(8),
yum(8),
dnf(8),
https://rpm-software-management.github.io/mock/
